<%@ page language="java" import="com.alibaba.fastjson.JSONArray" pageEncoding="UTF-8" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.BaseBean" %>
<%@ page import="weaver.general.Util" %>
<%--获取考试题目信息--%>
<%
    RecordSet rs = new RecordSet();
    JSONObject jsonData = new JSONObject();
    BaseBean bb = new BaseBean();
    String tmid = Util.null2String(request.getParameter("tmid"));
    bb.writeLog(">>>>>getKstmxx_Ajax>>>>tmid="+tmid);
    JSONArray childList = new JSONArray();
    rs.executeQuery("select id,ktlx from uf_ktsz where id=?", tmid);
    rs.next();
    String ktlx = Util.null2String(rs.getString("ktlx"));
    String mainid = Util.null2String(rs.getString("id"));
    bb.writeLog(">>>>>getKstmxx_Ajax>>>>mainid="+mainid);
    rs.executeQuery("select xx,ROW_NUMBER() over(order by px,id) px from uf_ktsz_dt1 where mainid=? order by px,id", mainid);
    while (rs.next()) {
        JSONObject json = new JSONObject();
        String xx = Util.null2String(rs.getString("xx"));
        int px = Util.getIntValue(rs.getString("px"));
        String xxmc = "";
        String xxnr = "";
        if ("0".equals(ktlx) || "1".equals(ktlx)) {
            xxmc = getKsxx(px);
            xxnr = xx;
        }
        if ("2".equals(ktlx)) {
            xxmc = xx;
        }
        json.put("xxid", px);
        json.put("xxnr", xxnr);
        json.put("xxmc", xxmc);
        bb.writeLog(">>>>>getKstmxx_Ajax>>>>json="+json);
        childList.add(json);
    }
    bb.writeLog(">>>>>getKstmxx_Ajax>>>>childList="+childList.toJSONString());
    jsonData.put("child", childList.toJSONString());
    out.print(jsonData.toJSONString());
%>
<%!
    /**
     * 转换考试选项
     */
    public String getKsxx(int val) {
        String[] strs = new String[]{"A. ", "B. ", "C. ", "D. ", "E. ", "F. ", "G. ", "H. ", "I. ", "J. ", "K. ", "L. ", "M. ", "N. "};
        return strs[val - 1];
    }

%>